<?php

namespace CNEPAdmin\Controller;

use CNEPAdmin\Controller\CommonController;

class PicController extends CommonController {

    protected $_modelName = "Pic";

    protected function setCode() {
        $this->_code = "System";
    }

    /**
     * 查看列表
     */
    public function index() {
        $this->checkPriv('pic', 1, false); // 权限

        $this->_getOnePageData("getPicList", "getPicListLength");
    }

    public function savePic() {
        $this->checkPriv("pic", 2);
        $id = intval(I("post.picID"));

        if ($id > 0) {
            $this->_updatePic();
        } else {
            $this->_addPic();
        }
        
    }

    private function _addPic() {
        $this->_ajaxOperate('addPic', '', '');
    }

    /**
     * 更新基本信息(需要更新什么就提交什么)
     */
    private function _updatePic() {
        
        $this->_ajaxOperate('updatePic', '', '');
    }

    /**
     * 删除
     */
    public function deletePic() {
        $this->checkPriv("pic", 2);

        $msgID = intval(I("post.picID"));

        if ($msgID > 0) {
            $this->_ajaxOperate('deletePic', '', '', $msgID);
        } else {
            $this->ajaxReturn(array(
                "result" => 0, "desc" => "无效ID"
            ));
        }
    }

}
